package com.flysky.model.common;

public class PagingModel {
	private Long curPage =1l;
	private Long totalCount;

	private Long totalPage;
	public static Long perPage = 5l;
	private Long startRec;
	private Long endRec;
	private Long startPage;
	private Long endPage;
	private Long perStage = 5l;

	public Long getCurPage() {
		return curPage;
	}

	public void setCurPage(Long curPage) {
		this.curPage = curPage;
	}

	public Long getTotalCount() {
		if(this.totalCount == null){
			this.totalCount = this.curPage * PagingModel.perPage;
		}
		return totalCount;
	}

	public void setTotalCount(Long totalCount) {
		this.totalCount = totalCount;
	}

	public Long getTotalPage() {
		totalPage =(long) Math.ceil((double)totalCount / (double)perPage);
		return totalPage;
	}

	public Long getPerPage() {
		return perPage;
	}

	public Long getStartRec() {
		startRec = (this.curPage - 1) * PagingModel.perPage + 1;
		return startRec;
	}

	public Long getEndRec() {
		endRec = Math.min(this.curPage * PagingModel.perPage, this.getTotalCount());
		return endRec;
	}

	public Long getStartPage() {
		startPage = ((long) Math.ceil((double)this.curPage / (double)this.perStage)-1)
				* this.perStage+1;
		return startPage;
	}

	public Long getEndPage() {
		endPage = Math.min(((long) Math.ceil((double)this.curPage / (double)this.perStage)) * this.perStage, this.getTotalPage());
		return endPage;
	}

	public Long getPerStage() {
		return perStage;
	}

	@Override
	public String toString() {
		return "PagingObj [getCurPage()=" + getCurPage() + ", getTotalCount()="
				+ getTotalCount() + ", getTotalPage()=" + getTotalPage()
				+ ", getPerPage()=" + getPerPage() + ", getStartRec()="
				+ getStartRec() + ", getEndRec()=" + getEndRec()
				+ ", getStartPage()=" + getStartPage() + ", getEndPage()="
				+ getEndPage() + ", getPerStage()=" + getPerStage() + "]";
	}

}
